GBML manual / Rooms

region_entered

True for one frame when the player arrives in a different region than the last one they were in: show the region's name, start a weather effect, give the player a hint. False in every other frame. It is true once when the game starts, for the region the player starts in, and again each time the player crosses into another region.

Syntax

region_entered() -> bool

Returns

bool

Description

True for one frame each time the player arrives in a different region than the last one they were in, and false in every other frame. Use it to show the region's name, start a weather effect or give a hint.

The game remembers the last region the player was in. A change is the player arriving in a region that is not that one, so:

It works the same way in a long room cut into regions: the player is the object the camera follows, and the frame after it walks across a border into another region this is true once.

It is true in the frame after the player crosses the border (the Step events of that frame see it), so every change is seen exactly once. When the change is made by a room change that fades the screen, it waits for the first frame the Step events run in.

Example

if (region_entered()) {
    log_write(region_name());
}

Writes the name of each new region to the log as the player arrives in it.

On the GBA

The game remembers the last region the player was in. Walking into a house (a room that is not part of a world) and coming back out into the same region is not a change, so it is not true then; coming out into a different region is. It is true in the frame after the player crosses the border (the Step events of that frame see it), and for exactly one frame, so each change is seen once. Going to another world with world_go() counts as leaving a region in the old world and entering one in the new world. Asking for it makes the game keep the table of regions, which costs a few bytes for each region.

See also: region_exitedregion_nameregion_currentregion_enterworld_goWhat a region does in the game